import Vue from 'vue';
import iView from 'iview';
import {router} from './router/index';
import {appRouter} from './router/router';
import store from './store';
import App from './App.vue';
import '@/locale';
import 'iview/dist/styles/iview.css';
import VueI18n from 'vue-i18n';
import depot from './libs/tool/depot';
import wangeditor from './libs/tool/wangeditor';
import directives from './libs/directives/index'; // 全局自定义指令
import url from './libs/url';
import $ from 'jquery';
import VueQuillEditor from 'vue-quill-editor';
import VueDND from 'awe-dnd'; // 拖拽组件
import lrz from 'lrz'; // 压缩图片组件
import 'vue2-event-calendar/default.css';
import Calendar from 'vue2-event-calendar';
import ba from 'vue-ba'
// import util from '@/libs/util';
/* 富文本样式详见styles */

// depot函数库挂载到window
Vue.use(VueI18n);
Vue.use(iView);
Vue.use(VueQuillEditor);
Vue.use(wangeditor);
Vue.use(VueDND);
Vue.component('Calendar', Calendar);
Vue.prototype.URL = url;
depot();
Vue.use(ba, "f1f9e7ad1cc3083cad04b2cc64491b77");
window.Vue = new Vue({
    el: '#app',
    router: router,
    store: store,
    ba:ba,
    render: h => h(App),
    data: {
        currentPageName: ''
    },
    mounted () {
        this.currentPageName = this.$route.name;
        // 显示打开的页面的列表
        this.$store.commit('setOpenedList');
        this.$store.commit('initCachepage');
        // 权限菜单过滤相关
        this.$store.commit('updateMenulist');
        // iview-admin检查更新
        // util.checkUpdate(this);
    },
    created () {
        directives();
        let tagsList = [];
        appRouter.map((item) => {
            if (item.children.length <= 1) {
                tagsList.push(item.children[0]);
            } else {
                tagsList.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsList);
    }
});
